﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tedds_Tool.Instructions;
using CommonInterfaces.Models;
using StandardScriptItems.SimpleControls;
using LEET.CommonInterfaces;
using LEET.CommonInterfaces.Models;
using System.Windows;
using LEET.StandardModuals.Instructions.Actions;

namespace Tedds_Tool.Automatables.LEETModuals.LEETHackModuals
{
    public class ScaleHack : ILEETHackModual
    {
        public const String SCALE_ANNOUNCER = "_____Scale:";
        public string Instruction(string strVal)
        {
            return strVal.Substring(SCALE_ANNOUNCER.Length).Replace("{", "").Replace("}", "").Replace(",", " |");
        }

        public string PropertyName
        {
            get { return "ScalePattern.Current.Size"; }
        }

        public static string HACK_FLAG = "Scale";
        public string HackFlag
        {
            get { return HACK_FLAG; }
        }

        public string ActionName
        {
            get { return "RESIZE"; }
        }

        public System.Windows.UIElement CreateScriptItemDetails()
        {
            throw new NotImplementedException();
        }

        public bool CanCompile(string instruction)
        {
            try
            {
                String[] parts = LEET.LEETCommon.Model.Instruction.ParseInstruction(instruction);
                return "ACTION".Equals(parts[0]) && TypeName.Equals(parts[1]);
            }
            catch (InvalidInstructionException)
            {
                return false;
            }
        }

        public IInstruction CreateInstruction(string instruction)
        {
            return new Resize(LEET.LEETCommon.Model.Instruction.ParseInstruction(instruction));
        }


        public string TypeName
        {
            get { return "RESIZE"; }
        }


        public FrameworkElement CreateScriptItemDetails(LEET.CommonInterfaces.Nil onUpdate, IEnumerable<string> processes, IElementState state)
        {
            ElementStateComboBox elem = new ElementStateComboBox(state);
            ScriptItemArgument arg1 = new ScriptItemArgument(elem, "-- X --");
            arg1.Name = "Argument1";
            ScriptItemArgument arg2 = new ScriptItemArgument(arg1, "-- Y --");
            arg2.Name = "Argument2";
            return arg2;
        }
    }
}
